﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ZLDC.Common.Estate;
using ZLDC.Topo.Model.Estate;

namespace ZLDC.Topo.BLL.Estate
{
    public class SystemOptionBLL
    {
                                                public static string p_system_option_listall_table(int typeid)
        {
            DataTable dt = null;
            
            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.SystemOptionDAL.p_system_option_listall_table(typeid, db);
            }

            _Json json = new _Json(dt);
            return "{record:" + json.ToJson() + "}";
        }

                                                                                                                                public static string p_system_option_save(int ID, int subsidiaryID, string subsidiary, int typeid, string item, int itemValue, string itemFieldName, string itemField, int dltFlg, string modifyUser, string remark,int grade)
        {
            string outmsg = ""; 
            int newid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.SystemOptionDAL.p_system_option_save(ID, subsidiaryID, subsidiary, typeid, item, itemValue, itemFieldName, itemField, dltFlg, modifyUser, remark, grade,out outmsg, out newid, db);
            }
            
            return outmsg;
        }

                                                public static SystemOptionInfo p_system_option_detail(string item)
        {
            using (_Database db = new _Database("estate"))
            {
                return ZLDC.DAL.Estate.SystemOptionDAL.p_system_option_detail(item, db);
            }
        }

                                                public static int GetOption(string item)
        {
            int result = 1;

                        object obj = _Cache.GetCache(item);
            if (obj != null)
            {
                result = (Int32)obj;
            }
            else
            {
                result = p_system_option_detail(item).ItemValue;

                _Cache.SetCache(item, result, 86400);
            }

            return result;
        }

    }
}
